<?php

namespace App\Http\Requests\Backend\Setting;

use Illuminate\Foundation\Http\FormRequest;

class SettingRepayRateRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $method = $this->method();
        switch ($method){
            case 'POST':
                return [
                    'channel_code' => 'bail|required',
                    'period' => 'bail|required|numeric',
                    'lending_rate' => 'bail|required|numeric',
                    'insurance_rate' => 'numeric',
                    'insure_rate' => 'numeric',
                    'month_insurance_rate' => 'bail|required|numeric',
                    'manage_rate' => 'bail|required|numeric',
                    'repayment_rate' => 'bail|required|numeric',
                    'fines_rate' => 'bail|required|numeric',
                ];
                break;
            case 'PUT':
                return [
                    'period' => 'numeric',
                    'lending_rate' => 'numeric',
                    'insurance_rate' => 'numeric',
                    'insure_rate' => 'numeric',
                    'month_insurance_rate' => 'numeric',
                    'manage_rate' => 'numeric',
                    'repayment_rate' => 'numeric',
                    'fines_rate' => 'numeric',
                ];
                break;
        }
    }

    public function messages()
    {
        return [
            'channel_code.required' => '请传递资方编号',
//            'period.required' => '请传递期数',
//            'period.numeric' => '请传递期数',
//            'period.required' => '请传递期数',
//            'period.required' => '请传递期数',

        ];
    }
}
